Security News
Cloudflare Adds Security.txt Setup Wizard
Cloudflare has launched a setup wizard allowing users to easily create and manage a security.txt file for vulnerability disclosure on their websites.
@peculiar/asn1-rsa
Advanced tools
ASN.1 schema of `RSA Cryptography Specifications Version 2.2` (RFC8017)
@peculiar/asn1-rsa is an npm package that provides ASN.1 schema definitions for RSA cryptographic algorithms. It is useful for encoding and decoding RSA keys and signatures in ASN.1 format, which is a standard interface for representing cryptographic data.
Encoding RSA Public Key
This code demonstrates how to encode an RSA public key into ASN.1 format using the @peculiar/asn1-rsa package.
const { RSAPublicKey } = require('@peculiar/asn1-rsa');
const { AsnConvert } = require('@peculiar/asn1-schema');
const publicKey = new RSAPublicKey({
modulus: new Uint8Array([0x00, 0x01, 0x02, 0x03]),
publicExponent: new Uint8Array([0x01, 0x00, 0x01])
});
const asn1PublicKey = AsnConvert.serialize(publicKey);
console.log(asn1PublicKey);
Decoding RSA Public Key
This code demonstrates how to decode an ASN.1 encoded RSA public key using the @peculiar/asn1-rsa package.
const { RSAPublicKey } = require('@peculiar/asn1-rsa');
const { AsnConvert } = require('@peculiar/asn1-schema');
const asn1PublicKey = new Uint8Array([/* ASN.1 encoded public key bytes */]);
const publicKey = AsnConvert.parse(asn1PublicKey, RSAPublicKey);
console.log(publicKey);
Encoding RSA Private Key
This code demonstrates how to encode an RSA private key into ASN.1 format using the @peculiar/asn1-rsa package.
const { RSAPrivateKey } = require('@peculiar/asn1-rsa');
const { AsnConvert } = require('@peculiar/asn1-schema');
const privateKey = new RSAPrivateKey({
version: 0,
modulus: new Uint8Array([0x00, 0x01, 0x02, 0x03]),
publicExponent: new Uint8Array([0x01, 0x00, 0x01]),
privateExponent: new Uint8Array([0x00, 0x01, 0x02, 0x03]),
prime1: new Uint8Array([0x00, 0x01]),
prime2: new Uint8Array([0x00, 0x01]),
exponent1: new Uint8Array([0x00, 0x01]),
exponent2: new Uint8Array([0x00, 0x01]),
coefficient: new Uint8Array([0x00, 0x01])
});
const asn1PrivateKey = AsnConvert.serialize(privateKey);
console.log(asn1PrivateKey);
Decoding RSA Private Key
This code demonstrates how to decode an ASN.1 encoded RSA private key using the @peculiar/asn1-rsa package.
const { RSAPrivateKey } = require('@peculiar/asn1-rsa');
const { AsnConvert } = require('@peculiar/asn1-schema');
const asn1PrivateKey = new Uint8Array([/* ASN.1 encoded private key bytes */]);
const privateKey = AsnConvert.parse(asn1PrivateKey, RSAPrivateKey);
console.log(privateKey);
node-forge is a comprehensive library for implementing various cryptographic algorithms in JavaScript. It includes support for RSA key generation, encryption, and decryption, as well as ASN.1 encoding and decoding. Compared to @peculiar/asn1-rsa, node-forge offers a broader range of cryptographic functionalities beyond just ASN.1 schema definitions.
asn1js is a library for encoding and decoding ASN.1 data structures in JavaScript. It provides low-level tools for working with ASN.1, including support for various cryptographic algorithms. While it is more general-purpose compared to @peculiar/asn1-rsa, it can be used to achieve similar results with more manual effort.
pkijs is a library built on top of asn1js that provides high-level APIs for working with public key infrastructure (PKI) and cryptographic operations. It includes support for RSA keys and certificates, making it a more comprehensive solution compared to @peculiar/asn1-rsa, which focuses specifically on ASN.1 schema definitions for RSA.
FAQs
ASN.1 schema of `RSA Cryptography Specifications Version 2.2` (RFC8017)
The npm package @peculiar/asn1-rsa receives a total of 190,120 weekly downloads. As such, @peculiar/asn1-rsa popularity was classified as popular.
We found that @peculiar/asn1-rsa demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 6 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Cloudflare has launched a setup wizard allowing users to easily create and manage a security.txt file for vulnerability disclosure on their websites.
Security News
The Socket Research team breaks down a malicious npm package targeting the legitimate DOMPurify library. It uses obfuscated code to hide that it is exfiltrating browser and crypto wallet data.
Security News
ENISA’s 2024 report highlights the EU’s top cybersecurity threats, including rising DDoS attacks, ransomware, supply chain vulnerabilities, and weaponized AI.